package com.prs.crm.domain.purchase;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.prs.crm.domain.FlowEntity;
import com.prs.crm.domain.stock.Purchase;
import com.prs.crm.domain.stock.Supplier;

/**
 * 供应商询价
 * 
 * @author
 * **/
@Entity
@Table(name = "stock_supplier_inquiry")
public class SupplierInquiry extends FlowEntity {

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
	private Purchase purchase;
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "supplierInquiry")
	@OrderBy
	private List<Inquiry> inquirys;
	@Lob
	private String remark;
	@Column(columnDefinition = "Integer(2) default '0'")
	private int processTag;
	@Column(columnDefinition = "Integer(2) default '0'")
	private int orderTag;
	@ManyToOne
	private Supplier supplier;

	public void addInquiry(Inquiry inquiry) {
		if (inquirys == null)
			inquirys = new ArrayList<Inquiry>();
		inquirys.add(inquiry);
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Purchase getPurchase() {
		return purchase;
	}

	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List<Inquiry> getInquirys() {
		return inquirys;
	}

	public void setInquirys(List<Inquiry> inquirys) {
		this.inquirys = inquirys;
	}

	public int getProcessTag() {
		return processTag;
	}

	public void setProcessTag(int processTag) {
		this.processTag = processTag;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public int getOrderTag() {
		return orderTag;
	}

	public void setOrderTag(int orderTag) {
		this.orderTag = orderTag;
	}

}
